<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="layout/template.xhtml">
	<ui:define name="content">
	
		<h:form id="fileBrowserForm" prependId="false">
			<h:outputLabel value="#{resourceBundle['sysInfo.diskList']}"/>
			<p:dataTable value="#{systemInfoBean.diskList}" var="row">
				<p:column>
					<f:facet name="header">
						<h:outputText value="Mountpoint"/>
					</f:facet>
					<p:commandLink process="@form" update=":fileBrowserForm:fileTable" value="#{row.mountPoint}" actionListener="#{fileBrowserBean.retrieveFileList}">
						<f:attribute name="folder" value="#{row.mountPoint}"/>
					</p:commandLink>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Total space"/>
					</f:facet>
					<h:outputText value="#{row.totalSpace}"/>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Used space"/>
					</f:facet>
					<h:outputText value="#{row.usedSpace}"/>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Free space"/>
					</f:facet>
					<h:outputText value="#{row.freeSpace}"/>
				</p:column>
			</p:dataTable>

			<br/>
			<br/>
			<h:outputLabel value="#{resourceBundle['sysInfo.fileBrowser']}"/>		
			<p:outputPanel >
				<p:dataTable id="fileTable" value="#{fileBrowserBean.fileList}" var="row">
					<p:column>
						<f:facet name="header">
							<h:outputText value="Name"/>
						</f:facet>
						<p:commandLink process="@all" value="#{row.name}" actionListener="#{fileBrowserBean.retrieveFileList}" oncomplete="updateFileTable()" rendered="#{row.directory}">
							<f:attribute name="folder" value="#{row.name}"/>
						</p:commandLink>
						<h:outputText value="#{row.name}" rendered="#{!row.directory}"/>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Type"/>
						</f:facet>
						<h:outputText value="#{(row.directory ? 'd' : 'f')}"/>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="length"/>
						</f:facet>
						<h:outputText value="#{row.length}"/>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Read"/>
						</f:facet>
						<h:outputText value="#{row.canRead}"/>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Write"/>
						</f:facet>
						<h:outputText value="#{row.canWrite}"/>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Exec"/>
						</f:facet>
						<h:outputText value="#{row.canExecute}"/>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="hidden"/>
						</f:facet>
						<h:outputText value="#{row.hidden}"/>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="lastModified"/>
						</f:facet>
						<h:outputText value="#{row.lastModified}"/>
					</p:column>
				</p:dataTable>
			</p:outputPanel>
			
			<p:remoteCommand name="updateFileTable" update=":fileBrowserForm:fileTable" process="@this" />
		</h:form>
	</ui:define>
</ui:composition>

</html>